/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.apli.haiam.ejb.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Informática
 */
@Entity
@Table(name = "adm_accion")
@NamedQueries({
    @NamedQuery(name = "AdmAccion.findAll", query = "SELECT a FROM AdmAccion a")})
public class AdmAccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_accion")
    private Short idAccion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "clave")
    private String clave;
    @Size(max = 256)
    @Column(name = "descripcion")
    private String descripcion;
    @JoinTable(name = "adm_rol_accion", joinColumns = {
        @JoinColumn(name = "id_accion", referencedColumnName = "id_accion")}, inverseJoinColumns = {
        @JoinColumn(name = "id_rol", referencedColumnName = "id_rol")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<AdmRol> admRolList;
    @ManyToMany(mappedBy = "admAccionList", fetch = FetchType.LAZY)
    private List<AdmMenu> admMenuList;
    @JoinColumn(name = "id_sistema", referencedColumnName = "id_sistema")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private AdmSistema admSistema;

    public AdmAccion() {
    }

    public AdmAccion(Short idAccion) {
        this.idAccion = idAccion;
    }

    public AdmAccion(Short idAccion, String nombre, String clave) {
        this.idAccion = idAccion;
        this.nombre = nombre;
        this.clave = clave;
    }

    public Short getIdAccion() {
        return idAccion;
    }

    public void setIdAccion(Short idAccion) {
        this.idAccion = idAccion;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getClave() {
        return clave;
    }

    public void setClave(String clave) {
        this.clave = clave;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public List<AdmRol> getAdmRolList() {
        return admRolList;
    }

    public void setAdmRolList(List<AdmRol> admRolList) {
        this.admRolList = admRolList;
    }

    public List<AdmMenu> getAdmMenuList() {
        return admMenuList;
    }

    public void setAdmMenuList(List<AdmMenu> admMenuList) {
        this.admMenuList = admMenuList;
    }

    public AdmSistema getAdmSistema() {
        return admSistema;
    }

    public void setAdmSistema(AdmSistema admSistema) {
        this.admSistema = admSistema;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAccion != null ? idAccion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AdmAccion)) {
            return false;
        }
        AdmAccion other = (AdmAccion) object;
        if ((this.idAccion == null && other.idAccion != null) || (this.idAccion != null && !this.idAccion.equals(other.idAccion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.apli.haiam.ejb.entidades.AdmAccion[ idAccion=" + idAccion + " ]";
    }
    
}
